<?php
namespace Admin\Controller;
use Think\Controller;
/**
 * Class MemberController
 * @package Admin\Controller
 * 2018-04-11   用户类
 */
class MemberController extends AdminBasicController{

    public $member = '';
    public function _initialize(){
        $this->checkLogin();
        $this->member = D('Member');
    }

    /**
     * 用户列表
     * @author mss
     * @time 2018-04-11
     */
    public function memberList(){
        $where = array();
        $param = array();
        $where['status'] = array('NEQ',9);
        $order = 'ctime DESC';
        /**按名称搜索*/
        if(!empty(trim(I('request.nickname')))){
            $title = trim(I('request.nickname'));
            $where['nick_name'] = array('LIKE','%'.$title.'%');
            $param['nickname'] = $title;
        }

        /**按发布时间查找*/
        if(!empty(I('request.start_time')) && !empty(I('request.end_time'))){
            $start_time = I('request.start_time');
            $this->assign("start_time",$start_time);
            $end_time = I('request.end_time');
            $this->assign("end_time",$end_time);
            $where['ctime'] = array(array('EGT',strtotime($start_time)),array('ELT',strtotime($end_time)),'and');
            $parameter['start_time'] = I('request.start_time');
            $parameter['end_time'] = I('request.end_time');
        }

        $list = $this->member->selectMember($where,$order,15,$param);
        $data = $list['list'];

        $this->assign('list',$data);
        $this->assign('page',$list['page']);
        $this->assign('request',$_REQUEST);

        $this->display('memberList');
    }


    /**
     * 删除用户
     * @author mss
     * @time 2018-04-11
     */
    public function delMember(){
        if(empty($_REQUEST['m_id'])){
            $this->error('您未选择任何操作对象');
        }
        $where['m_id'] = array('IN',I('request.m_id'));
        $data['status'] = 9;
        $data['utime'] = time();
        $upd_res = $this->member->editMember($where,$data);
        if($upd_res){
            //其他删除操作

            $this->success('删除操作成功');
        }else{
            $this->error('删除操作失败');
        }
    }

  

}